<template>
	<view class="container">
		<view class="scanArea" @click="scan"></view>
		<view class="text" @click="scan">扫描地块码</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				taskId:'',
				landId:''
			};
		},
		onLoad(routerParams) {
			this.taskId = routerParams.id
		},
		methods:{
			scan(){
				uni.showLoading({
					mask:true,
					title:''
				})
				uni.scanCode({
					success: (res) => {
						console.log(res);
						this.landId = res.result
						if(this.taskId && this.landId){
							uni.hideLoading()
							uni.redirectTo({
								url:`/pages/operator/orderAddTask?taskId=${this.taskId}&landId=${this.landId}`
							})
						}
					},
					fail: (err) => {
						uni.hideLoading()
						uni.$u.toast("获取地块信息失败")
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.container{
		position: relative;
		 .scanArea{
			position: absolute;
			top: 156rpx;
			left:136rpx;
			width: 478rpx;
			height: 478rpx;
			border: 4rpx solid #17cc17;
			border-radius: 12rpx;
			background-color: #ffffff;
		}
		.text{
			position: absolute;
			top: 723rpx;
			left:290rpx;
		}
	}
</style>
